package cn.com.surker.report.bean;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;

import java.util.ArrayList;
import java.util.List;

/**
 * 工作薄中的每行数据
 *
 * @author luotao
 * @date 2024/5/15
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ExcelRow {

	/**
	 * 行高
	 */
	private short height;

	/**
	 * 列的值
	 */
	private List<ExcelCell> cells;

	/**
	 * 添加单元格数据
	 *
	 * @param cellValue
	 */
	public void addCell(Object cellValue) {
		if (cells == null) {
			cells = new ArrayList<>();
		}
		if (cellValue == null) {
			cellValue = "";
		}
		ExcelCell cell = new ExcelCell(cellValue);
		cells.add(cell);
	}

	public void addCell(ExcelStyle style, Object cellValue) {
		if (cells == null) {
			cells = new ArrayList<>();
		}
		if (cellValue == null) {
			cellValue = "";
		}
		ExcelCell cell = new ExcelCell(cellValue);
		cell.setCellStyle(style);
		cells.add(cell);
	}
}
